<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
	"http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-type" content="text/html; charset=utf-8">
		<title>Test of util.js</title>
		<script src="util.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<p>Browser: <span id="browser"></span></p>
		<table width="300px">
			<caption>Parameters (Query Arguments)</caption>
			<tr id="params"></tr>
		</table>
		<table width="300px">
			<caption>Cookies</caption>
			<tr id="cookies"></tr>
		</table>
		<table>
			<caption>Set a new cookie</caption>
			<tr>
				<th>Name</th>
				<td><input type="text" name="cname"/></td>
			</tr>
			<tr>
				<th>Value</th>
				<td><input type="text"name="cvalue"/></td>
			</tr>
			<tr>
				<th></th>
				<td><input type="button" name="setcookie" value="Set cookie" onClick="newCookie();"/></td>
			</tr>
		</table>
		<table width=300px>
			<caption>Pretty evaluate expression</caption>
			<tr>
				<th>Expression</th>
				<td><input type="text" name="expr"/></td>
			</tr>
			<tr>
				<th></th>
				<td><input type="button" value="Evaluate" onClick="dumpObject();"></td>
			</tr>
		</table>
		<div id="dump"></div>
	</body>
	<script type="text/javascript" charset="utf-8">
		var elem = document.getElementById('browser');
		elem.innerHTML = navigator.userAgent;
		elem = document.getElementById('params');
		var params = getParams();
		for (var param in params) {
			//setCookie(param, params[param]);
			elem.innerHTML += ("<tr><th>" + param + "</th><td>" + params[param] + "</td></tr>");
		}
		refreshCookiesView();
		
		function refreshCookiesView() {
			elem = document.getElementById('cookies');
			var cookies = getCookies();
			elem.innerHTML = "";
			for (var cookie in cookies) {
				elem.innerHTML += ("<tr><th>" + cookie + "</th><td>" + cookies[cookie] + "</td></tr>");
			}
		}
		
		function newCookie() {
			var name = document.getElementsByName("cname")[0].value;
			var value = document.getElementsByName("cvalue")[0].value;
			setCookie(name, value);
			refreshCookiesView();
		}
		
		function dumpObject() {
			var table = document.getElementById('dump');
			var newtable = pretty_eval(document.getElementsByName("expr")[0].value);
			table.appendChild(newtable);
		}
	</script>
</html>
